{include file="public/header" /}
<link rel="stylesheet" href="/static/admin/css/base.css" media="all">
<style>
    html {
        background-color: #f2f2f2 !important;
    }

    .layui-form-item {
        margin-bottom: 0 !important;
    }

    .underline {
        text-decoration: underline;
        color: #00a2d4
    }

    tr th:last-child {
        border-right: 0 !important;
    }

    .grid-demo {
        background: #fff;
        justify-content: center;
        align-items: center;
        text-align: center;
        padding: 10px;
        /*margin-right: 10px;*/
        /*margin-left: 10px;*/
        border-radius: 10px;
    }

    .layui-col-md2 {

        padding: 5px;
    }

    .card-header {
        padding: 10px;
        margin-bottom: 10px;
    }

    .card-header h3 {
        font-weight: bolder;
    }

</style>
<body>
<div class="layui-fluid layui-anim-fadein">

    <div class="layui-row">
        {foreach name="task" item="vo"}
        <div class="layui-col-md2">
            <div class="grid-demo">
                <div class="card-header" style="font-size: 18px;font-weight: bolder">{$vo.title}</div>
                <div class="layui-btn-container">
                    <button data-type="{$vo.type}"
                            class="execute layui-btn layui-btn-normal layui-btn-sm">
                        点击执行
                    </button>
                    <button data-type="{$vo.type}"
                            class="record layui-btn layui-btn-danger layui-btn-sm">执行记录
                    </button>
                </div>

            </div>
        </div>
        {/foreach}

    </div>

</div>
{foreach name="task" item="vo"}
<div class="{$vo.type}" style="display: none;">
    <div style="padding: 10px;border-radius: 10px">
        <table class="layui-table">
            <colgroup>
                <col width="150">
                <col width="200">
                <col width="100">
                <col width="100">
                <col width="150">
                <col>
            </colgroup>
            <thead>
            <tr>
                <th>管理员</th>
                <th>执行时间</th>
                <th>方法</th>
                <th>IP</th>
                <th>运行时间</th>
                <th>状态</th>
            </tr>
            </thead>
            <tbody>
            {foreach name="vo.record" item="vo" key="key"}
            {if $key < 11}
            <tr>
                <td>{$vo.admin}</td>
                <td>{:date('Y/m/d H:i:s',$vo.times)}</td>
                <td>{$vo.method}</td>
                <td>{$vo.ip}</td>
                <td>{$vo.required*1000}ms</td>
                <td>{$vo.status}</td>
            </tr>
            {/if}
            {/foreach}

            </tbody>
        </table>
    </div>
</div>
{/foreach}
</body>
{include file="public/footer" /}
<script>
    $(".record").click(function () {
        var type = $(this).attr('data-type');
        layer.open({
            type: 1,
            title: false,
            area: '900px',
            shade: 0.8,
            id: 'LAY_layuipro',
            anim: 4,
            moveType: 1,
            content: $("." + type),
        });
    });

    $(".execute").click(function () {
        var type = $(this).attr('data-type');
        layer.confirm('仅限测试使用！是否继续？', {title: '请确认'}, function (index) {
            layer.close(index);
            layer.msg('<div><i class="layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop"></i> 加载中....', {
                shade: 0.8,
                time: 99999
            });

            $.post('{:url("test/execute")}', {type: type}, function (data) {
                layer.closeAll();
                if (data.code == 1) {
                    layer.msg(data.msg, {icon: 1, time: 1000}, function () {
                        location.reload();
                    });
                } else {
                    layer.msg(data.msg, {icon: 2, time: 1000}, function () {
                        location.reload();
                    })
                }
            });
        });
    });


</script>
</html>